package com.nsn.auction.domina;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="PRICE")
public class Price implements Serializable{
	
	private long actual;
	private long minimum;
	private long buyNow;
	private long winPrice;
	private Long priceId;
	
	public Price() {}
	
	public Price(long minimum, long buyNow) {
		this.minimum = minimum;
		this.buyNow = buyNow;
	}
	
	public Price(long actual) {
		this.actual = actual;
	}
	
	public long getActual() {
		return actual;
	}
	
	public void setActual(long actual) {
		this.actual = actual;
	}
	
	@Column(name="MINIMAL_PRICE", nullable = true)
	public long getMinimum() {
		return minimum;
	}
	
	public void setMinimum(long minimum) {
		this.minimum = minimum;
	}
	
	@Column(name="BUY_NOW", nullable = true)
	public long getBuyNow() {
		return buyNow;
	}
	
	public void setBuyNow(long buyNow) {
		this.buyNow = buyNow;
	}
	
	@Column(name="WIN_PRICE", nullable = true)
	public long getWinPrice() {
		return winPrice;
	}
	
	public void setWinPrice(long winPrice) {
		this.winPrice = winPrice;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name="PRICE_ID", unique = true, nullable = false)
	public Long getPriceId() {
		return priceId;
	}

	public void setPriceId(long priceId) {
		this.priceId = priceId;
	}
	
	@Override
	public boolean equals(Object object) {
		
		//check for selt-comparison
		if (this == object) return true;
		if (!( this.getClass().equals(object.getClass()) )) return false;
		
		Price temp_price = (Price) object;
		 return (0 == getActual() ? 0 == temp_price.getActual() : getActual() == temp_price.getActual() && 
				0 == getMinimum() ? 0 == temp_price.getMinimum() : getMinimum() == temp_price.getMinimum() &&
				0 == getBuyNow() ? 0 == temp_price.getBuyNow() : getBuyNow() == temp_price.getBuyNow());
	}
	
	
	

}
